package com.example.demo.controller;

import com.example.demo.model.Ffmana;
import com.example.demo.service.IFfmanaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Administrator 张少婷
 */

@Api(tags = "物品发放信息")
@RestController
@RequestMapping("/swagger12")
public class FfmanaController {
    @Autowired
    private IFfmanaService ffmanaService;
    @CrossOrigin
    @ApiOperation(value="添加发放物品信息")
    @PostMapping("/insertFfmana")
    public int insertFfmana(@RequestBody Ffmana ffmana){
        System.out.println("进入添加发放物品信息信息接口" );
        return ffmanaService.insertFfmana(ffmana);
    }

    @PostMapping("/getAllFfmana")
    public List<Ffmana> getAllFfmana(@RequestBody Ffmana ffmana)
    {
        System.out.println("进入查询方法");
        List<Ffmana> listFfmana=ffmanaService.getAllFfmana(ffmana);
        return listFfmana;
    }
    @PostMapping("/editFfmana")
    public int EditFfmana(@RequestBody Ffmana ffmana){
        System.out.println("添加修改方法");
        return ffmanaService.updateFfmana(ffmana);
    }
    @GetMapping("/delFfmana")
    public int Delete(int lbid){
        System.out.println("进入删除方法");
        int returnValues=0;
        if(lbid!=0){
            Ffmana ffmana=new Ffmana();
            ffmana.setLbid(lbid);
            returnValues=ffmanaService.deleteFfmana(ffmana);
        }
        return returnValues;
    }

    @GetMapping("/getOneFfmana")
    public Ffmana getFfmana(int lbid){
        Ffmana ffmana=new Ffmana();
        System.out.println("进入单条查询方法");
        if(lbid!=0){
            Ffmana ffmana1=new Ffmana();
            ffmana1.setLbid(lbid);
            ffmana=ffmanaService.getFfmana(ffmana1);
            System.out.println("返回的数据集合为:"+ffmana.getLbid());
        }
        return ffmana;
    }
}
